home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / General / MWC & CodeResources / ReadMe < prev    next >
Text File  |  1994-01-13  |  4KB  |  87 lines

  1. =================================================
  2. TechNote: Metrowerks C/C++ 68k and Code Resources
  3. =================================================
  4.  
  5. Created 13-Jan-94 by Andreas Hommel
  6.  
  7. The files in this folder are some examples for creating code resources, DAs and
  8. device drivers with Metrowerks C. MWC supports global data in code resources. This
  9. global data is accessed using the A4 register. However the programmer is responsible
  10. for setting this A4 register before using global data (see example files).
  11.  
  12. MWC also supports multiple code segments. To unload a code segment use the
  13. pascal void UnloadA4Seg(void *); function just as you would use the UnloadSeg() function
  14. in an application.
  15.  
  16. All code resources, DAs and device drivers will be entered through the main function.
  17.  
  18. WDEF.c is a skeleton WDEF code resource that shows how to use global data within code
  19. resources and how to handle callback functions.
  20.  
  21. DRVR_DA.c is a skeleton device driver / DA that shows how to dispatch from main.
  22.  
  23. "SetUpA4.h" and "A4Stuff.h" are some header files that did not make it into the DR1
  24. CodeWarrior release (the "A4Stuff.h" definitions were previously defined in MacHeaders.c
  25. and the "SetUpA4.h" stuff was missing).
  26.  
  27. Libraries and code resources/DAs/Drivers:
  28. -----------------------------------------
  29. Any library that uses global/static data must have been compiled as an A4 library when
  30. beeing used in a code resources/DA/Driver. You cannot use ANSI.lib, CPlusPlus.Lib... .
  31. Use ANSIA4.lib, CPlusPlusA4.Lib... instead. Only MacOS.lib is a universal library that
  32. can be used in both applications and code resources/DAs/Drivers. To create an A4 library
  33. Make a library using a project where the project type is set to CodeResource.
  34.  
  35. Single segment code resources/DAs/Drivers:
  36. ------------------------------------------
  37. • one segment
  38. • near code/data only
  39. • maximum 32k code
  40. • maximum 32k data
  41. • only simple constant initializations are supported. This implies:
  42.     no pointer inits as in "char *ptr="foo";" (however "char arr[]="foo";" works fine).
  43.     no virtual function tables
  44.  
  45. Multi segment code resources/DAs/Drivers:
  46. -----------------------------------------
  47. • multiple segments
  48. • near and far code/data
  49.  
  50. C++ and code resources/DAs/Drivers:
  51. -----------------------------------
  52. • initialization code is not yet supported. This implies:
  53.     no global static class objects with constructors or destructors.
  54.     no global static data objects with non-constant initialization
  55.     (non-constant pointer initialization is allowed "char *ptr="foo";")
  56.  
  57. The following Resources are generated when creating:
  58. ----------------------------------------------------
  59. single segment LDEF resource 123:
  60. LDEF 123                        //    code resource
  61.  
  62. multi segment CDEF resource 123 (3 segments):
  63. CDEF 123    /    CDEx 123        //    code resource segment 1 + relocation resource
  64. CDEc 124    /    CDEx 124        //    code resource segment 2 + relocation resource
  65. CDEc 125    /    CDEx 125        //    code resource segment 3 + relocation resource
  66.  
  67. single segment driver/DA 123;
  68. DRVR 123                        //    the driver/DA
  69.  
  70. multi segment driver/DA 123 (3 segments):
  71. DRVR 123                        //    generic driver/DA code
  72. DRVc 123    /    DRVx 123        //    driver segment 1 + relocation resource
  73. DRVc 124    /    DRVx 124        //    driver segment 2 + relocation resource
  74. DRVc 125    /    DRVx 125        //    driver segment 3 + relocation resource
  75.  
  76. Code Resource Header:
  77. ---------------------
  78. The header of a code reource will always look like this:
  79.  
  80. //    bra.s    __Startupcode__
  81. //    dc.w    0
  82. //    dc.l    Code Resource Type        //    WDEF/CDEF/MDEF/LDEF/XTND...
  83. //    dc.w    Code Resource ID        //    resource id
  84. //    dc.w    Version (0)
  85. //    __Startupcode__:
  86. //        jmp        main
  87.